package com.joysuch.wwyt.core.entity;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import com.joysuch.wwyt.risk.entity.RiskStableEvalution;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * @author qingzhou
 * 2019-12-17
 */
@Data
@Entity
@Table(name = "wwyt_base_config")
@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
public class BaseConfig {


    private Long id;
    private Long typeId;
    private Long tenentId;
    private String orgCode;
    private String code;
    private String value;
    private String description;

    private Integer isRequired;

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "type_id")
    public Long getTypeId() {
        return typeId;
    }

    public void setTypeId(Long typeId) {
        this.typeId = typeId;
    }

    @Column(name = "tenent_id")
    public Long getTenentId() {
        return tenentId;
    }

    public void setTenentId(Long tenentId) {
        this.tenentId = tenentId;
    }

    @Column(name = "org_code")
    public String getOrgCode() {
        return orgCode;
    }

    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }

    @Column(name = "code")
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Column(name = "value")
    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Column(name = "description")
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId()).append("tenentId", getTenentId())
                .append("orgCode", getOrgCode()).append("code", getCode()).append("typeID",getTypeId())
                .append("value", getValue()).append("description",getDescription()).toString();
    }

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof BaseConfig == false)
            return false;
        if (this == obj)
            return true;
        BaseConfig other = (BaseConfig) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }

}
